Fix: audio encoder uses full attention instead of windowed on non-FA2 backends#103
Open
Dvad wants to merge 1 commit intoQwenLM:mainfrom
Open
Fix: audio encoder uses full attention instead of windowed on non-FA2 backends#103Dvad wants to merge 1 commit intoQwenLM:mainfrom
Dvad wants to merge 1 commit intoQwenLM:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug: Qwen3ASRAudioEncoder.forward() passes
cu_seqlensto attention layers but never builds a 4D attention mask. Only Flash Attention 2 (CUDA) interprets cu_seqlens for windowed attention boundaries.On SDPA/eager backends (MPS, CPU), cu_seqlens is ignored and the encoder performs full global self-attention over all tokens instead of the trained windowed attention pattern.
This causes significant quality degradation on non-CUDA hardware (~340 words transcribed vs ~555 expected on a 5-minute test clip).
Fix: Call the existing _prepare_attention_mask() method (which already returns None for FA2) and pass the resulting block-diagonal mask to each encoder layer.
Verified on: MPS (Apple Silicon), CPU.
FA2 path is unchanged (
_prepare_attention_maskreturnsNonefor flash_attention_2).